package com.lmy.springboot.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 可以使用@WebServlet注入自定义的servlet(继承了HttpServlet)
 * 1.urlPatterns = {"/myServlet"} 表示对servlet配置了映射路径
 * 2.注入的原生的servlet不会被 springboot 的拦截器拦截，但是还是会被过滤器拦截
 * 3.对于开发的原生的servlet，需要在springboot主程序使用@ServletComponentScan来指定要扫描的原生的servlet对应的包及其子包，
 *   才会注入到 spring 容器
 */
@WebServlet(urlPatterns = {"/myServlet"})
public class Servlet_ extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().write("hello,servlet");
    }


}
